package cn.wen.forum.common.result;

import cn.wen.forum.common.enums.ResultCode;
import lombok.Data;

/**
* @ClassName Result
* @Author BY wen
* @date 2023/3/16 9:50
* @Version 1.0 返回体构造器
*/
@Data
public class Result {
    private Long total;
    private String message;
    private String code;
    private Object data;

    public static JSONResult success() {
        return new JSONResult(true);
    }

    public static <T> JSONResult<T> success(T data) {
        return new JSONResult(true, data);
    }

    public static <T> JSONResult<T> success(ResultCode resultEnum, T data) {
        return new JSONResult(true, resultEnum, data);
    }

    public static JSONResult fail() {
        return new JSONResult(false);
    }

    public static JSONResult fail(ResultCode resultEnum) {
        return new JSONResult(false, resultEnum);
    }

    public static JSONResult fail(String message) {
        return new JSONResult(false, message);
    }

    public Result() {
    }

    public Result(Long total,Object data) {
        this.total = total;
        this.data = data;
    }

    public Result(String message, String code) {
        this.message = message;
        this.code = code;
    }

    public Result(Long total, String message, String code, Object data) {
        this.total = total;
        this.message = message;
        this.code = code;
        this.data = data;
    }

    /*  public PageResult(Long total, List<PostDoc>  posts) {
        this.total = total;
        this.posts = posts;
    }*/
}
